package com.cy.myblog.model;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;


@Entity
@Table(name="tuser")
public class Tuser implements Serializable{

	/**
	 * 用户实体类
	 */
	private static final long serialVersionUID = -2446510311312979231L;

	private String id;
	private String account;
	private String password;
	private String realname;
	private String name;
	private Date birthdate;
	private Character sex;
	private String phone;
	private String qq;
	private String homepage;
	private String interests;
	private String email;
	private Date creatime;
	private Date logintime;
	private String ipaddress;
	private Integer state;
	private Set<Tarticle> tarticles;
	
	public Tuser(){
		super();
	}

	public Tuser(String id, String account, String password, String realname,
			String name, Date birthdate, Character sex, String phone, String qq,
			String homepage, String interests, String email, Date creatime,
			Date logintime, String ipaddress, Integer state) {
		super();
		this.id = id;
		this.account = account;
		this.password = password;
		this.realname = realname;
		this.name = name;
		this.birthdate = birthdate;
		this.sex = sex;
		this.phone = phone;
		this.qq = qq;
		this.homepage = homepage;
		this.interests = interests;
		this.email = email;
		this.creatime = creatime;
		this.logintime = logintime;
		this.ipaddress = ipaddress;
		this.state = state;
	}

	@Id
	@Column(name = "id", unique = true, nullable = false, length = 38)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "account",unique = true, nullable = false, length = 20)
	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	@Column(name = "password", nullable = false, length = 32)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "realname", length = 20)
	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	@Column(name = "name", nullable = false, length = 20)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "birthdate")
	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	@Column(name = "sex", length = 10)
	public Character getSex() {
		return sex;
	}

	public void setSex(Character sex) {
		this.sex = sex;
	}

	@Column(name = "phone", length = 20)
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "qq",length = 20)
	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Column(name = "homepage", length = 50)
	public String getHomepage() {
		return homepage;
	}

	public void setHomepage(String homepage) {
		this.homepage = homepage;
	}

	@Column(name = "interests")
	public String getInterests() {
		return interests;
	}

	public void setInterests(String interests) {
		this.interests = interests;
	}

	@Column(name = "email", length = 30)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "creatime")
	public Date getCreatime() {
		return creatime;
	}

	public void setCreatime(Date creatime) {
		this.creatime = creatime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "logintime")
	public Date getLogintime() {
		return logintime;
	}

	public void setLogintime(Date logintime) {
		this.logintime = logintime;
	}

	@Column(name = "ipaddress", length = 30)
	public String getIpaddress() {
		return ipaddress;
	}

	public void setIpaddress(String ipaddress) {
		this.ipaddress = ipaddress;
	}

	@Column(name = "state", length = 11)
	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}
	
	@OneToMany(mappedBy = "tuser")
	@LazyCollection(LazyCollectionOption.EXTRA)
	public Set<Tarticle> getTarticles() {
		return tarticles;
	}

	public void setTarticles(Set<Tarticle> tarticles) {
		this.tarticles = tarticles;
	}

	@Override
	public String toString() {
		return "Tuser{" +
				"id='" + id + '\'' +
				", account='" + account + '\'' +
				", password='" + password + '\'' +
				", realname='" + realname + '\'' +
				", name='" + name + '\'' +
				", birthdate=" + birthdate +
				", sex=" + sex +
				", phone='" + phone + '\'' +
				", qq='" + qq + '\'' +
				", homepage='" + homepage + '\'' +
				", interests='" + interests + '\'' +
				", email='" + email + '\'' +
				", creatime=" + creatime +
				", logintime=" + logintime +
				", ipaddress='" + ipaddress + '\'' +
				", state=" + state +
				'}';
	}
}
